<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>

    <style type="text/css">

        .login-page {
            width: 360px;
            padding: 10% 0 0;
            margin: auto 67%;
        }

        .form {

            position: relative;
            z-index: 1;
            /* background: #FFFFFF;*/
            background-size: cover;
            background-image: url("images/背景矩形.png");
            max-width: 360px;
            margin: 0 auto 100px;
            padding: 45px;
            height: 260px;
            text-align: center;
            box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
        }

        .form input {
            font-family: "Roboto", sans-serif;
            outline: 0;
            background: #f2f2f200;
            width: 100%;
            border: 1px solid #64646852;
            margin: 0 0 15px;
            padding: 15px;
            box-sizing: border-box;
            font-size: 14px;
            color: aliceblue;

        }

        .form button {
            font-family: "Microsoft YaHei", "Roboto", sans-serif;
            text-transform: uppercase;
            outline: 0;
            background: #4565c2;
            width: 100%;
            border: 0;
            padding: 15px;
            color: #FFFFFF;
            font-size: 14px;
            cursor: pointer;
        }

        .form button:hover, .form button:active, .form button:focus {
            background: #497fe0;
        }

        /*  .form .message a {
            color: #4CAF50;
            text-decoration: none;
        }
*/
        .container .info h1 {
            margin: 0 0 15px;
            padding: 0;
            font-size: 36px;
            font-weight: 300;
            color: #1a1a1a;
        }

        .container .info span {
            color: #4d4d4d;
            font-size: 12px;
        }

        .container .info span a {
            color: #000000;
            text-decoration: none;
        }

        .container .info span .fa {
            color: #EF3B3A;
        }

        body {
            /* background-image: url("images/背景.png");
             background-size: 93%;*/
            /*background: linear-gradient(to left, #f3f2f2, #ffffff);
            font-family: "Roboto", sans-serif;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;*/
            margin: 0;
            padding: 0;
        }

        .shake_effect {
            -webkit-animation-name: shake;
            animation-name: shake;
            -webkit-animation-duration: 1s;
            animation-duration: 1s;
        }

        @-webkit-keyframes shake {
            from, to {
                -webkit-transform: translate3d(0, 0, 0);
                transform: translate3d(0, 0, 0);
            }

            10%, 30%, 50%, 70%, 90% {
                -webkit-transform: translate3d(-10px, 0, 0);
                transform: translate3d(-10px, 0, 0);
            }

            20%, 40%, 60%, 80% {
                -webkit-transform: translate3d(10px, 0, 0);
                transform: translate3d(10px, 0, 0);
            }
        }

        @keyframes shake {
            from, to {
                -webkit-transform: translate3d(0, 0, 0);
                transform: translate3d(0, 0, 0);
            }

            10%, 30%, 50%, 70%, 90% {
                -webkit-transform: translate3d(-10px, 0, 0);
                transform: translate3d(-10px, 0, 0);
            }

            20%, 40%, 60%, 80% {
                -webkit-transform: translate3d(10px, 0, 0);
                transform: translate3d(10px, 0, 0);
            }
        }

        img {
            width: 20%;
            height: auto;
            position: absolute;
            margin: 2%;
        }

        h5 {
            color: red;
            padding: 0;
            margin: 0;
            position: absolute;
        }

        #login_form {
            position: relative;
        }

        input::-webkit-input-placeholder {
            color: #ffffff;
        }

        input:focus{
            border-color: #667cff !important;
            outline: 0;

        }
    </style>
</head>
<body>
<img src="images/背景1.png" style="position: absolute;width: 100%;height: 100%;margin: 0;padding: 0">
<div class="htmleaf-container">
    <img src="images/白色版logo.png">
    <div id="wrapper" class="login-page">
        <div id="login_form" class="form">

            <div style="margin-top: -5px;color: #ffffff;font-family: SimHei;font-size: 28px;margin-bottom: 20px; ">用户登录</div>
            <form class="login-form" style="color:#ffffff;position: relative" autocomplete="off">
                <i style="background-image: url('assets/images/yonghuming.png');position: absolute;width: 20px;height: 20px;top: 8%;left: 4%;"></i>
                <i style="background-image: url('assets/images/ai-password.png');background-size: cover;position: absolute;width: 20px;height: 20px;top: 45%;left: 4%;"></i>
                <input style="padding-left: 40px;" type="text" placeholder="用户名" id="user_name" autocomplete="off"/>
                <input style="padding-left: 40px;" type="password" placeholder="密码" id="password" autocomplete="off"/>
                <button id="login">登　录</button>
                <h5 id="message"></h5>
            </form>
        </div>
    </div>
</div>

<script src="js/jquery.min.js"></script>
<script src="js/jquery.cookie.js"></script>
<script>
    var user = $.cookie('uu');

    $(document).ready(function () {
        // 判断是否存在cookie
        if (user) {
            $("#user_name").val(user);
        }

    });

</script>
<script type="text/javascript">


    $(function () {

        $("#login").click(function () {
            $.cookie('uu', $("#user_name").val(), {expires: 365});
            login();
            return false;
        })

    });

    function login() {

        var name = $("#user_name").val();
        var pass = $("#password").val();

        $.ajax({
            "url": "/backend/login/",
            "data": "username=" + name + "&password=" + pass,
            "type": "POST",
            "dataType": "json",
            "success": function (json) {

                if (json.state == 200) {

                    /* $.cookie("uid", json.data.uid, {expires: 7 });*/

                    location.href = "index.html#miao";
                } else {
                    $("#message").html(json.message);
                    $("#login_form").removeClass('shake_effect');
                    setTimeout(function () {
                        $("#login_form").addClass('shake_effect')
                    }, 1);
                }
            }
        })
    }

</script>

</body>
</html>